<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - entropy_encoder_model_kernel_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2004  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_ENTROPY_ENCODER_MODEL_KERNEl_ABSTRACT_
<font color='#0000FF'>#ifdef</font> DLIB_ENTROPY_ENCODER_MODEL_KERNEl_ABSTRACT_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../algs.h.html'>../algs.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> alphabet_size,
        <font color='#0000FF'>typename</font> entropy_encoder
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='entropy_encoder_model'></a>entropy_encoder_model</b> 
    <b>{</b>
        <font color='#009900'>/*!
            REQUIREMENTS ON alphabet_size
                1 &lt; alphabet_size &lt; 65535

            REQUIREMENTS ON entropy_encoder
                is an implementation of entropy_encoder/entropy_encoder_kernel_abstract.h

            INITIAL VALUE
                Initially this object is at some predefined empty or ground state.

            WHAT THIS OBJECT REPRESENTS
                This object represents some kind of statistical model.  You
                can use it to write symbols to an entropy_encoder and it will calculate
                the cumulative counts/probabilities and manage contexts for you.

                Note that all implementations of entropy_encoder_model and 
                entropy_decoder_model are paired. This means that if you use 
                entropy_encoder_model_kernel_n to encode something then you must 
                use the corresponding entropy_decoder_model_kernel_n to decode it.

                Also note that this object does not perform any buffering of symbols.  It
                writes them to its associated entropy_encoder immediately.
                This makes it safe to use multiple entropy_encoder_model objects with
                a single entropy_encoder without them trampling each other.
        !*/</font>

    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>typedef</font> entropy_encoder entropy_encoder_type;
    
        <b><a name='entropy_encoder_model'></a>entropy_encoder_model</b> <font face='Lucida Console'>(</font>
            entropy_encoder<font color='#5555FF'>&amp;</font> coder
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - &amp;#get_entropy_encoder() == &amp;coder
            throws
                - any exception
        !*/</font>

        <font color='#0000FF'>virtual</font> ~<b><a name='entropy_encoder_model'></a>entropy_encoder_model</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - all memory associated with *this has been released
        !*/</font>

        <font color='#0000FF'><u>void</u></font> <b><a name='clear'></a>clear</b><font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this has its initial value
                - does not modify get_entropy_encoder()
            throws
                - any exception
                    if this exception is thrown then *this is unusable 
                    until clear() is called and succeeds
        !*/</font>

        <font color='#0000FF'><u>void</u></font> <b><a name='encode'></a>encode</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> symbol
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            requires
                - symbol &lt; alphabet_size
            ensures
                - encodes and writes the symbol to get_entropy_encoder().
                  This also means that there is no internal buffering.  symbol is
                  written immediately to the entropy_encoder.
            throws
                - any exception
                    If this exception is thrown then #*this is unusable until 
                    clear() is called and succeeds.
        !*/</font>

        entropy_encoder<font color='#5555FF'>&amp;</font> <b><a name='get_entropy_encoder'></a>get_entropy_encoder</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - returns a reference to the entropy_encoder used by *this
        !*/</font>

        <font color='#0000FF'>static</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='get_alphabet_size'></a>get_alphabet_size</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - returns alphabet_size
        !*/</font>

    <font color='#0000FF'>private</font>:

        <font color='#009900'>// restricted functions
</font>        <b><a name='entropy_encoder_model'></a>entropy_encoder_model</b><font face='Lucida Console'>(</font>entropy_encoder_model<font color='#5555FF'>&lt;</font>alphabet_size,entropy_encoder<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;        <font color='#009900'>// copy constructor
</font>        entropy_encoder_model<font color='#5555FF'>&lt;</font>alphabet_size,entropy_encoder<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>entropy_encoder_model<font color='#5555FF'>&lt;</font>alphabet_size,entropy_encoder<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;    <font color='#009900'>// assignment operator
</font>
    <b>}</b>;   

<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_ENTROPY_ENCODER_MODEL_KERNEl_ABSTRACT_
</font>

</pre></body></html>